﻿using UnityEngine;

public class Mainloop : MonoBehaviour {
    #region singleton
    static Mainloop _instance;

    public static Mainloop Instance
    {
        get
        {
            GameObject mainLoopGO = GameObject.Find("Mainloop");
            if (mainLoopGO == null)
            {
                mainLoopGO = (GameObject)Instantiate(Resources.Load("Prefabs/Mainloop"));
                
            }
            _instance = mainLoopGO.GetComponent<Mainloop>();
            return _instance;
        }
    }

    private void Awake()
    {
        DontDestroyOnLoad(gameObject);
        OnAwake();
    }
    #endregion

    public Ctrl ctrl { private set; get; }

    private void OnAwake()
    {
        ctrl = new Ctrl();
        ctrl.changeProc(ProcType.PROC_INIT);
    }


    void Update ()
    {
        ctrl.Update();
    }


    public int MyPlayerID;

    private void OnApplicationQuit()
    {
        Network.NetManager.Instance.Close(); 
    }
}
